package icu.qx.index.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import icu.qx.index.domain.CommonData;
import icu.qx.index.service.IProStatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/index")
public class IndexController extends BaseController {

    @Autowired
    private IProStatisticService proStatisticService;

    @GetMapping("/getIndex")
    public AjaxResult getInfo() {
        List<CommonData> indexNumList = proStatisticService.selectTotalNum();
        return success(indexNumList);
    }

    @GetMapping("/getDrawbackRange")
    public AjaxResult getDrawbackRange() {
        List<CommonData> drawbackRange = proStatisticService.selectDrawbackRange();
        return success(drawbackRange);
    }

    @GetMapping("/getBadProcedure")
    public AjaxResult getBadProcedure() {
        List<CommonData> badProcedure = proStatisticService.selectBadProcedure();
        return success(badProcedure);
    }

    @GetMapping("/getDateResult")
    public AjaxResult getWeek(@RequestParam("date") Integer date) {
        switch (date) {
            case 30:
                return success(proStatisticService.totalMonthTasks());
            case 365:
                return success(proStatisticService.totalYearTasks());
            default:
                return success(proStatisticService.totalWeekTasks());
        }
    }
}
